﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<Shamrock.Helpers.PaginatedList<Shamrock.Models.Message>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Shamrock
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <hr />
    [<%: Html.RouteLink("回到版面", "IndexThreads", new{page=0}) %>]
    <div class="replyBar">回應模式</div>
    <% Html.RenderPartial("MessageForm", ViewData["NewMessage"]); %>
    <hr />

    <div class="threads">
    <% var item = (Shamrock.Models.Message)ViewData["ThreadPost"]; %>
        <div class="threadStructure" id="thread<%: item.MessageID %>">
            <div class="threadPost" id="r<%: item.MessageID %>">
                <span class="subject" id="threadSubject<%: item.MessageID %>"><%: item.SubjectDefault %></span>
                Name
                <span class="name">
                <% if (item.Email != null) { %>
                <a href="mailto:<%: item.Email %>"><%: item.PosterDefault %></a>
                <% }else{ %>
                <%: item.PosterDefault %>
                <% } %>
                </span>
                [<%: item.PostDateWithWeekday %>]
                <span class="postID">No.<%: item.MessageID %></span>
                <div class="comment">
                    <%= Html.Encode(item.CommentDefault).Replace("\n", "<br />") %>
                </div>
            </div>

            <% foreach (var reply in Model) { %>
            <div class="reply" id="r<%: reply.MessageID %>">
                <span class="subject" id="replySubject<%: reply.MessageID %>"><%: reply.SubjectDefault %></span>
                Name
                <span class="name">
                <% if (reply.Email != null) { %>
                <a href="mailto:<%: reply.Email %>"><%: reply.PosterDefault %></a>
                <% }else{ %>
                <%: reply.PosterDefault %>
                <% } %>
                </span>
                [<%: reply.PostDateWithWeekday %>]
                <span class="postID">No.<%: reply.MessageID %></span>
                <div class="comment">
                    <%= Html.Encode(reply.CommentDefault).Replace(Environment.NewLine, "<br />") %>
                </div>
            </div>
            <% } %>
        </div>
        <hr />
    </div>

    <div class="pagination">
        <table>
        <tr>
            <td>
            <% if (Model.HasPreviousPage) { %>        
                <%: Html.RouteLink("上一頁", 
                                   "ReplyPosts", 
                                   new { page=(Model.PageIndex-1) }) %>
            <% }else{ %>
                第一頁
            <% } %>
            </td>
            <td>
            <% for (int i = 0; i < Model.TotalPages; i++){ %>
                <% if (i != Model.PageIndex) { %>
                    [<%: Html.RouteLink(i.ToString(),
                                       "ReplyPosts", 
                                       new { page=(i) }) %>]
                <% } else { %>
                    [<%: i %>]
                <% } %>
            <% } %>
            <% if(Model.TotalPages > 1){ %>
                <% if(!Model.DisplayingAllPages) { %>
                [<%:Html.RouteLink("All", "ShowAllReplies") %>]
                <% }else{ %>
                [All]
                <% } %>
            <% } %>
            </td>
            <td>
            <% if (Model.HasNextPage) { %>        
                <%: Html.RouteLink("下一頁", 
                                   "ReplyPosts", 
                                   new { page=(Model.PageIndex+1) }) %>
            <% }else{ %>
                最後一頁
            <% } %>
            </td>
        </tr>
        </table>
    </div>

</asp:Content>

